<?php
// enable Session
session_start();
if(strtoupper($_SESSION['code']) == strtoupper($_POST['code'])) {
    echo "输入正确！";
} else {
    echo "输入错误";
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>验证码</title>
    </head>
    <body>
        <form class="" action="reg.php" method="post">
            用户名： <input type="text" name="username" value="">
            密码： <input type="text" name="password" value="">
            验证码： <input type="text" maxsize="4" name="code" value="">
            <img src="code.php" alt="" onclick="this.src = 'code.php?' +Math.random()"/>
            <input type="submit" name="name" value="登陆">
        </form>
    </body>
</html>
